{extend name="public:common_edit"/}
{block name="main"}

<style>
    .tipStyle {
        display: none;
        position: absolute;
        background-color: #FBEC88;
        font-size: 16px;
        border-right: #D0EAF9 solid 1px;
        border-bottom: #D0EAF9 solid 1px;
        border-left: #D0EAF9 solid 1px;
        border-top: #D0EAF9 solid 1px;
    }

</style>

<div id="kyqToolTip" class="tipStyle"></div>

    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-list"></i> 用户列表</h3>
        </div>
        <div class="panel-body">

            <div class="navbar navbar-default">
                <form action="" id="search-form2" class="navbar-form form-inline" method="get" onsubmit="return false">
                    <div class="form-group">
                        <label class="control-label" >昵称或手机号:</label>
                        <div class="input-group">
                            <input type="text" name="nick_name" value="{$Think.get.nick_name}" placeholder="请输入昵称或手机号"
                             class="form-control">
                        </div>

                    </div>
                    <div class="form-group">
                        <label class="control-label" >等级:</label>
                        <div class="input-group">
                            <input type="text" name="level" value="{$Think.get.level}" placeholder="等级"
                                   class="form-control">
                        </div>

                    </div>

                    <label class="control-label" >状态</label>
                    <select class="form-control" name="status">
                        <option id="status" value="">全部</option>
                        <option id="status1" value="1">启用</option>
                        <option id="status0" value="0">禁用</option>
                    </select>
                    <label class="control-label" >性别</label>
                    <select class="form-control" name="sex">
                        <option id="sex" value="">全部</option>
                        <option id="sex1" value="1">男</option>
                        <option id="sex2" value="2">女</option>
                    </select>
                    <div class="form-group">
                        <label class="control-label" for="input-order-id">注册时间</label>
                        <div class="input-group">
                            <input type="text"   name="startDate"  autocomplete="off" value="{$Think.get.startDate}" placeholder="选择开始时间"
                                   class="form-control timepicker">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <input type="text"   name="endDate"  autocomplete="off" value="{$Think.get.endDate}" placeholder="选择结束时间"
                                   class="form-control timepicker">
                        </div>
                    </div>

                    <button type="submit" onclick="javascript:document.getElementById('search-form2').submit();"
                            id="button-filter search-order" class="btn btn-primary"><i class="fa fa-search"></i> 筛选
                    </button>
                    <label class="control-label">用户总钻石:{$cash+$money}&nbsp;
                        可提现钻石:{$cash} &nbsp;不可提现钻石:{$money}
                        <span style="color: red">&nbsp;ps:每5分钟刷新一次钻石汇总</span> </label>

                    <a href="{:url('user_edit')}" class="btn btn-primary pull-right"><i class="fa fa-plus"></i>添加</a>
                    <a  onclick="add()" class="btn btn-primary pull-right"><i class="fa fa-volume-up"></i>发布推送</a>
                    <a href="customer"  class="btn btn-primary pull-right"><i class="fa fa-volume-up"></i>客服消息</a>
                </form>
            </div>
            <div id="ajax_return">
                <form method="post" enctype="multipart/form-data" target="_blank" id="form-order">
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover">
                            <thead>
                            <tr>
                                <td>用户id/hash</td>
                                <td>昵称</td>
                                <td>头像</td>
                                <td>手机号码</td>
                                <td>性别</td>
                                <td>等级</td>
                                <td>上次登录IP(双击封禁)</td>
                                <td>上次登录设备号(双击封禁)</td>

                                <td>可消费钻石</td>
                                <td>可提现钻石</td>
                                <td>总钻石</td>
                                <td>注册日期</td>
                                <td>状态</td>
                                <td>操作</td>
                            </tr>
                            </thead>
                            <tbody>
                            <!-- 列表循环开始 -->
                            {volist name="rows" id="row" key="key"}
                            <tr>
                                <td>{$row.user_id}/{:hashid($row.user_id)}</td>
                                <td class="emojstext">{$row.nick_name}</td>
                                <td><img modal="zoomImg" src="{$row.header_img}" style="max-width: 100px" alt=""></td>
                                <td>{$row.phone}</td>
                                <td>{if condition="$row.sex == 1"} 男 {else /} 女 {/if}</td>
                                <td>{$row.level}</td>
                                <td class="doubleBtn" data-ip="{$row.ip}" data-id="{$row.user_id}">{$row.ip}</td>
                                <td class="doubleBtn" data-ip="{$row.IMEI}" data-id="{$row.user_id}">{$row.IMEI}</td>
                                <td>{:num($row.money)}</td>
                                <td>{:num($row.cash)}</td>
                                <td>{:num($row.cash + $row.money)}</td>
                                <td>{$row.create_time}</td>
                                <td>{if condition="$row.status == 1"} 启用 {else /} 禁用 {/if}</td>
                                <td>
                                    <a class="btn btn-primary " onclick="openUri('/user/user_edit/id/{$row.user_id}')" >编辑</a>
                                    <a class="btn btn-primary"  href="/user/detail/id/{$row.user_id}">资金明细</a>
                                    {if condition="$row.status == 1"} <span class="btn btn-primary success">禁用 </span>
                                    <span class="btn btn-primary change" style="display: none" data-message="" data-url="/user/change/id/{$row.user_id}/type/0">禁用 </span>
                                    {else /} <span class="btn btn-primary change" data-message="" data-url="/user/change/id/{$row.user_id}/type/1">启用</span> {/if}


                                    {/*:url('user/user_pass',['id'=>$row.user_id])*/}
                                    <!--<span class="btn btn-danger check_del" data-message="" data-url="">删除</span>-->
                                </td>
                            </tr>
                            {/volist}
                            <!-- 列表循环结束 -->
                            </tbody>
                        </table>
                    </div>
                </form>
            </div>
            <div class="modal fade" id="bjy-add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times;</button>
                            <h4 class="modal-title" id="myModalLabel"> 发布推送</h4></div>
                        <div class="modal-body">
                            <form id="bjy-form" class="form-inline" action="{:url('user/Push')}" method="post"><input
                                    type="hidden" name="pid" value="0">
                                <table class="table table-striped table-bordered table-hover table-condensed">
                                    <tr>
                                        <th>推送内容：</th>
                                        <td><input class="form-control" type="text" name="title"></td>
                                    </tr>
                                    <tr>
                                        <th width="20%">指定用户：</th>
                                        <td>
                                            <input class="form-control" placeholder="用户id" type="text" name="user_id">
                                            <span style="color: red">ps:不填用户id默认推送给所有用户</span>
                                        </td>

                                    </tr>
                                    <tr>
                                        <th></th>
                                        <td><input class="btn btn-success submit" type="submit" value="发布"></td>
                                    </tr>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal fade" id="customer" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times;</button>
                            <h4 class="modal-title" id="myModalLabel1">客服消息</h4></div>
                        <div class="modal-body">
                            <form id="bjy-for" class="form-inline" action="{:url('user/customer')}" method="post">
                                <table class="table table-striped table-bordered table-hover table-condensed">
                                    <tr>
                                        <td>图片:</td>
                                        <td>{:uploadHtml('img','','single_img')}</td>
                                    </tr>
                                    <tr>
                                        <th>推送内容：</th>
                                        <td><input class="form-control" type="text" name="title"></td>
                                    </tr>
                                    <tr>
                                        <th>跳转链接：</th>
                                        <td><input class="form-control" type="text" name="url"></td>
                                    </tr>
                                    <tr>
                                        <th width="20%">指定用户：</th>
                                        <td>
                                            <input class="form-control" placeholder="用户id" type="text" name="user_id">
                                            <span style="color: red">ps:不填用户id默认推送给所有用户</span>
                                        </td>

                                    </tr>
                                    <tr>
                                        <th></th>
                                        <td><input class="btn btn-success submit" type="submit" value="发布"></td>
                                    </tr>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <div id='pagerarea'>{$pageHTML}</div>
        </div>
    </div>
{/block}
{block name="js"}

<script src="__JS__/boxImg.js" type="text/javascript" ></script>
<link rel="stylesheet" type="text/css" href="__CSS__/boxImg.css">


<script>


    $(".doubleBtn").on("dblclick", function(){
        var html    = $(this).data('ip');
        var user_id = $(this).data('id');
        var message = '将要封禁设备(ip):'+html;
        var url = "{:url('band')}?IMEI="+html+'&user_id='+user_id;
        layer.confirm(message, {
            btn: ['继续','放弃'] //按钮
        }, function(){
            $.ajax({
                url: url,
                type: 'GET',
                async: false,
                cache: false,
                contentType: false,
                processData: false,
                success: function (result) {
                    if (result.code == 1) {
                        successRedirect(result.msg, result.url, 1);
                    } else {
                        zcAlert(result.msg,0);
                        layer.closeAll("loading");
                        btn.attr('disabled', false);
                    }
                },
                error: function () {
                    layer.msg('请求失败,网络连接超时', {icon: 5, time: 2000});
                    layer.closeAll("loading");
                    btn.attr('disabled', false);
                }
            });
        }, function(){
            layer.msg('操作已取消');
        });

    });

    function openUri(uri) {
        layer.open({
            type: 2,
            title: '用户信息编辑',
            shadeClose: true,
            shade: 0.8,
            area: ['90%', '90%'],
            content:uri //iframe的url
        });
    }


    var pointX;
    var pointY;

    $('.success').click(function () {
        var _that = $(this);

        layer.prompt({title: '封禁时间(小时 0为永久封禁)', formType: 0}, function(pass, index){
            layer.close(index);
            var url = $($(_that).next('.change')).data('url');
            url += '?end_time='+pass;
            $($(_that).next('.change')).data('url',url);
            $($(_that).next('.change')).click();
        });



    });

    function showTip(str){

        if(str.length > 0){
            $("#kyqToolTip").css("display","block");
            $("#kyqToolTip").css("left",pointX+10);
            $("#kyqToolTip").css("top",pointY-10);
            $("#kyqToolTip").html(str);
        }
    }

    // 添加菜单
    $(".txtstyle").bind("mouseover",function(e){
        pointX = e.pageX;
        pointY = e.pageY;
        var html = $(this).data('str');
        html = jEmoji.softbankToUnified(html);
        html = jEmoji.googleToUnified(html);
        html = jEmoji.docomoToUnified(html);
        html = jEmoji.kddiToUnified(html);
        showTip(jEmoji.unifiedToHTML(html));
    }).bind("mouseout",function(e){
        closeTip()
    }).bind("mousedown",function(e){
        closeTip()
    });

    function closeTip() {
        $("#kyqToolTip").css("display","none");
    }


    var status   = "{$Think.get.status}";
    if(status != ''){
        $('#status'+status).attr('selected',true)
    }

    var sex   = "{$Think.get.sex}";
    if(sex != ''){
        $('#sex'+sex).attr('selected',true)
    }
    function add() {
        $("input[name='title'],input[name='name']").val('');
        $("input[name='pid']").val(0);
        $('#bjy-add').modal('show');
    }

    function customer() {
        $("input[name='title'],input[name='url'],input[name='user_id']").val('');
        $('#customer').modal('show');
    }


    $(function () {

        $.each($('.emojstext'),function (k,v) {
            var $text = $(v);
            var html = $text.html().trim().replace(/\n/g, '<br/>');
            html = jEmoji.softbankToUnified(html);
            html = jEmoji.googleToUnified(html);
            html = jEmoji.docomoToUnified(html);
            html = jEmoji.kddiToUnified(html);
            $text.html(jEmoji.unifiedToHTML(html));
        });

        var is_agent = "{$Think.get.is_agent}";
        $('#is_agent'+is_agent).attr('selected','selected')
    })
</script>
{/block}




